package com.joysuch.wwyt.common.controller;

import com.joysuch.wwyt.common.service.MailSettingService;
import com.joysuch.wwyt.core.bean.MailSettingBean;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 邮箱配置
 * @Author ZhangDong
 * @Date 2020/6/10 11:20
 */
@RestController
@RequestMapping("/common/mail/setting")
@Api(tags = "/common/mail/setting 邮箱配置")
public class MailSettingController {

    @Autowired
    private MailSettingService mailSettingService;

    @PostMapping("save")
    @ApiOperation("保存/修改")
    @RequiresPermissions("common:mail:setting:save")
    public ResultBean save(@Valid @RequestBody MailSettingBean bean) {
        return mailSettingService.save(bean);
    }

    @GetMapping("get")
    @ApiOperation("单体查询")
    public ResultBean get(Long id) {
        return mailSettingService.get(id);
    }

    @GetMapping("page")
    @ApiOperation("分页查询")
    public ResultBean page(Pageable pageable) {
        return mailSettingService.page(pageable);
    }

    @GetMapping("delete")
    @ApiOperation("删除")
    @RequiresPermissions("common:mail:setting:delete")
    public ResultBean delete(Long id) {
        return mailSettingService.delete(id);
    }
}
